package org.example.config;

import org.example.utils.Redis;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;

@Configuration
public class RedisConfig {
    //这里将Redis这里的对象交给spring自动管理但是，blogcommon没有启动类
    //如果将这个包给打包的话，需求并不是这样的
    //所以我们将springboot启动扫描的文件给创建出来
    @Bean
    @ConditionalOnProperty(prefix = "spring.data.redis",name = "host")
    public Redis redis  (StringRedisTemplate redisTemplate) {
        return new Redis(redisTemplate);
    }
}
